/**
 * 
 */
package dao;

import java.sql.SQLException;

import utils.Const;
import com.j256.ormlite.dao.Dao;
import database.DatabaseHelper;
import entity.Plan;
import entity.Reference;

/**
 * @author Hung
 *
 */
public class ReferenceDAO {
	
	private Dao<Reference, Integer> dao = null;
	
	public ReferenceDAO(DatabaseHelper helper) throws Exception {
		dao = helper.getReferenceDao();
		if (dao == null)
			throw new Exception(Const.NULL_DAO_ERROR);
	}
	
	public int createReference(Reference reference) throws SQLException {
		return dao.create(reference);
	}
	
	public int updateReference(Reference reference) throws SQLException {
		return dao.update(reference);
	}
	
	public int deleteReference(Reference reference) throws SQLException {
		return dao.delete(reference);
	}
	
	public Reference getReferenceById(int id) throws SQLException {
		return dao.queryForId(id);
	}
}
